#import "RNFavorites.h"
#import "RNConstants.h"

static RNFavorites *sharedFavorites;

@implementation RNFavorites

@synthesize icon = icon_;

+(RNFavorites *)sharedFavorites {
    if (!sharedFavorites) 
        sharedFavorites = [[self alloc] init];
    return sharedFavorites;
}

-(id)init {
    if (!(self = [super init]))
        return nil;
    
    [self setIcon:[NSImage imageNamed:@"sourceList_favorites.png"]];
    return self;
}

-(NSString *)title {
    return @"Favorites";
}

-(NSArray *)children {
    return nil;
}

-(id)parent {
    return nil;
}

-(BOOL)canContainObjectsWithEntityNames:(NSArray *)entityNames {
    NSArray *validEntities = [entityNames filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"self IN { %@, %@, %@ }", RNEntityNameItem, RNEntityNameListItem, RNEntityNameHistoryItem]];
    return [validEntities count] == [entityNames count];
}

-(NSDictionary *)objectDictionary {
    NSMutableDictionary *objectDictionary = [NSMutableDictionary dictionary];
    [objectDictionary setValue:[self title] forKey:RNTitleKey];
    [objectDictionary setValue:[self icon] forKey:@"icon"];
    return objectDictionary;
}

@end
